import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Class7 extends JFrame {
	private JPanel jPanel1 = new JPanel();

	private JComboBox jbox = new JComboBox();

	private JTextField jTextField1 = new JTextField(5);

	private JButton jButton1 = new JButton();

	private JButton jButton2 = new JButton();

	int s1;

	int s2;

	int s3;

	public Class7() {
		try {
			jbInit();
		} catch (Exception e) {
			e.printStackTrace();
		}

		jButton2.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				if (jTextField1.isEditable()) {
					int i = jbox.getSelectedIndex();
					if (i == 0)
						if (jTextField1.getText() != null && !"".equals(jTextField1.getText().trim()))
							s1 = Integer.parseInt(jTextField1.getText().trim());
					if (i == 1)
						if (jTextField1.getText() != null && !"".equals(jTextField1.getText().trim()))
							s2 = Integer.parseInt(jTextField1.getText().trim());
					if (i == 2)
						if (jTextField1.getText() != null && !"".equals(jTextField1.getText().trim()))
							s3 = Integer.parseInt(jTextField1.getText().trim());
					System.out.println("s1==" + s1 + ":s2==" + s2 + ":s3==" + s3);
				}

			}

		});
		jButton1.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				jTextField1.setText((s1 + s2 + s3) + "");

			}

		});
	}

	public static void main(String[] args) {
		Class7 class7 = new Class7();
		class7.setSize(300, 200);
		class7.setVisible(true);
		class7.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	private void jbInit() throws Exception {
		jButton1.setText("计算");
		jButton2.setText("付值");
		jPanel1.add(jbox, null);
		jPanel1.add(jTextField1, null);
		jPanel1.add(jButton2, null);
		jPanel1.add(jButton1, null);

		this.getContentPane().add(jPanel1, null);
		jbox.addItem("第1个数");
		jbox.addItem("第2个数");
		jbox.addItem("第3个数");

	}
}